using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.IO;
namespace etbTOEIC
{
	/// <summary>
	/// Summary description for frmMakeSoundTape.
	/// </summary>
	public class frmMakeSoundTape : System.Windows.Forms.Form
	{
		private Lybra.Forms.Controls.GradientPanelXP gradientPanelXP1;
		private System.Windows.Forms.Label label4;
		private Lybra.Forms.Controls.HoverGradientButton hoverGradientButtonCancel;
		private Lybra.Forms.Controls.HoverGradientButton hoverGradientButtonMakeTape;
		private Lybra.Forms.Controls.HoverGradientButton hoverGradientButtonFolder;
		private System.Windows.Forms.TextBox txtFolder;
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;
		private System.Windows.Forms.TreeView TreeViewExam;

		public frmMakeSoundTape(TreeView trv)
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();
			TreeViewExam = trv;
			//
			// TODO: Add any constructor code after InitializeComponent call
			//
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(frmMakeSoundTape));
			this.gradientPanelXP1 = new Lybra.Forms.Controls.GradientPanelXP();
			this.hoverGradientButtonFolder = new Lybra.Forms.Controls.HoverGradientButton();
			this.txtFolder = new System.Windows.Forms.TextBox();
			this.label4 = new System.Windows.Forms.Label();
			this.hoverGradientButtonCancel = new Lybra.Forms.Controls.HoverGradientButton();
			this.hoverGradientButtonMakeTape = new Lybra.Forms.Controls.HoverGradientButton();
			this.gradientPanelXP1.SuspendLayout();
			this.SuspendLayout();
			// 
			// gradientPanelXP1
			// 
			this.gradientPanelXP1.BackColor1 = System.Drawing.Color.Gainsboro;
			this.gradientPanelXP1.BackColor2 = System.Drawing.Color.Gray;
			this.gradientPanelXP1.Controls.Add(this.hoverGradientButtonFolder);
			this.gradientPanelXP1.Controls.Add(this.txtFolder);
			this.gradientPanelXP1.Controls.Add(this.label4);
			this.gradientPanelXP1.Controls.Add(this.hoverGradientButtonCancel);
			this.gradientPanelXP1.Controls.Add(this.hoverGradientButtonMakeTape);
			this.gradientPanelXP1.Dock = System.Windows.Forms.DockStyle.Fill;
			this.gradientPanelXP1.Font = new System.Drawing.Font("Arial", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.gradientPanelXP1.Gradient = System.Drawing.Drawing2D.LinearGradientMode.Vertical;
			this.gradientPanelXP1.Location = new System.Drawing.Point(0, 0);
			this.gradientPanelXP1.Name = "gradientPanelXP1";
			this.gradientPanelXP1.Size = new System.Drawing.Size(500, 141);
			this.gradientPanelXP1.TabIndex = 2;
			// 
			// hoverGradientButtonFolder
			// 
			this.hoverGradientButtonFolder.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(64)), ((System.Byte)(64)), ((System.Byte)(64)));
			this.hoverGradientButtonFolder.BackColor2 = System.Drawing.Color.RoyalBlue;
			this.hoverGradientButtonFolder.BorderHover = true;
			this.hoverGradientButtonFolder.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.hoverGradientButtonFolder.Font = new System.Drawing.Font("Arial", 11.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.hoverGradientButtonFolder.Location = new System.Drawing.Point(455, 30);
			this.hoverGradientButtonFolder.Name = "hoverGradientButtonFolder";
			this.hoverGradientButtonFolder.Size = new System.Drawing.Size(29, 24);
			this.hoverGradientButtonFolder.TabIndex = 15;
			this.hoverGradientButtonFolder.Text = "...";
			this.hoverGradientButtonFolder.Click += new System.EventHandler(this.hoverGradientButtonFolder_Click);
			// 
			// txtFolder
			// 
			this.txtFolder.Font = new System.Drawing.Font("Arial", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.txtFolder.Location = new System.Drawing.Point(147, 30);
			this.txtFolder.Name = "txtFolder";
			this.txtFolder.Size = new System.Drawing.Size(298, 25);
			this.txtFolder.TabIndex = 8;
			this.txtFolder.Text = "";
			// 
			// label4
			// 
			this.label4.BackColor = System.Drawing.Color.Transparent;
			this.label4.Font = new System.Drawing.Font("Arial", 11F);
			this.label4.ForeColor = System.Drawing.Color.Blue;
			this.label4.Location = new System.Drawing.Point(11, 30);
			this.label4.Name = "label4";
			this.label4.Size = new System.Drawing.Size(123, 24);
			this.label4.TabIndex = 7;
			this.label4.Text = "Output Folder :";
			this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
			// 
			// hoverGradientButtonCancel
			// 
			this.hoverGradientButtonCancel.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(64)), ((System.Byte)(64)), ((System.Byte)(64)));
			this.hoverGradientButtonCancel.BackColor2 = System.Drawing.Color.RoyalBlue;
			this.hoverGradientButtonCancel.BorderHover = true;
			this.hoverGradientButtonCancel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.hoverGradientButtonCancel.Font = new System.Drawing.Font("Arial", 11.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.hoverGradientButtonCancel.Location = new System.Drawing.Point(273, 84);
			this.hoverGradientButtonCancel.Name = "hoverGradientButtonCancel";
			this.hoverGradientButtonCancel.Size = new System.Drawing.Size(104, 40);
			this.hoverGradientButtonCancel.TabIndex = 6;
			this.hoverGradientButtonCancel.Text = "Cancel";
			this.hoverGradientButtonCancel.Click += new System.EventHandler(this.hoverGradientButtonCancel_Click);
			// 
			// hoverGradientButtonMakeTape
			// 
			this.hoverGradientButtonMakeTape.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(64)), ((System.Byte)(64)), ((System.Byte)(64)));
			this.hoverGradientButtonMakeTape.BackColor2 = System.Drawing.Color.RoyalBlue;
			this.hoverGradientButtonMakeTape.BorderHover = true;
			this.hoverGradientButtonMakeTape.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.hoverGradientButtonMakeTape.Font = new System.Drawing.Font("Arial", 11.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.hoverGradientButtonMakeTape.Location = new System.Drawing.Point(145, 84);
			this.hoverGradientButtonMakeTape.Name = "hoverGradientButtonMakeTape";
			this.hoverGradientButtonMakeTape.Size = new System.Drawing.Size(104, 40);
			this.hoverGradientButtonMakeTape.TabIndex = 5;
			this.hoverGradientButtonMakeTape.Text = "Make Tape";
			this.hoverGradientButtonMakeTape.Click += new System.EventHandler(this.hoverGradientButtonMakeTape_Click);
			// 
			// frmMakeSoundTape
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(500, 141);
			this.ControlBox = false;
			this.Controls.Add(this.gradientPanelXP1);
			this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
			this.Name = "frmMakeSoundTape";
			this.ShowInTaskbar = false;
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Tag = "etbTOEIC - Make SoundTape for Listenning Comprehension";
			this.Text = "etbTOEIC - Make SoundTape for Listenning Comprehension";
			this.Load += new System.EventHandler(this.frmMakeSoundTape_Load);
			this.gradientPanelXP1.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion

		private void hoverGradientButtonFolder_Click(object sender, System.EventArgs e)
		{
			FolderBrowserDialog fdlg = new FolderBrowserDialog();
			if(fdlg.ShowDialog() == DialogResult.OK)
				txtFolder.Text = fdlg.SelectedPath;
		}

		private void hoverGradientButtonMakeTape_Click(object sender, System.EventArgs e)
		{
			string stFolder = txtFolder.Text;
			if(Directory.Exists(stFolder))
				Directory.Delete(stFolder,true);
			Directory.CreateDirectory(stFolder);
			stFolder += "\\" ;
			string stSrcFolder = Environment.CurrentDirectory + "\\Sounds\\";
			DB2MainForm.MakeExamTape(DB2MainForm.TestID, TreeViewExam, stSrcFolder , stFolder);
			this.Close();

		}

		private void hoverGradientButtonCancel_Click(object sender, System.EventArgs e)
		{
			this.Close();
		}

		private void frmMakeSoundTape_Load(object sender, System.EventArgs e)
		{
			string stFolder = DB2MainForm.TestID.ToString();
			if(stFolder.Length < 5)
				stFolder = stFolder.PadLeft(5,'0');
			stFolder = DB2MainForm.ExamCode + "_" + stFolder;
			stFolder = Directory.GetCurrentDirectory() + "\\Output\\" + stFolder;
			txtFolder.Text = stFolder;
		
		}
	}
}
